python sort 2d list

30

python sort 2d list -

data = [['ABC', 12, 3, 100],
        ['DEF', 10, 5, 200],
        ['GHI', 13, 3, 1000]]

data.sort(key=lambda row: (row[2], row[3]), reverse=True)

print(data)

# [['DEF', 10, 5, 200], ['GHI', 13, 3, 1000], ['ABC', 12, 3, 100]]

Comments

Submit
0 Comments